home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / knowhow4 / blpxtab.cpp < prev    next >
C/C++ Source or Header  |  1994-10-10  |  5KB  |  141 lines

  1. #include "blpxtab.h"
  2.  
  3. BlockPXTable::BlockPXTable(rect coordinates,
  4.            char* tabName,
  5.            char* fName,
  6.            char* h,
  7.            int s,
  8.            BORDERS b_type,
  9.            BORDERS hdr_b_type,
  10.            int res,
  11.            int hdr_pat,
  12.            int elem_pat,
  13.            int fNo,
  14.            char** fields,
  15.            char** types)
  16.     : Block(coordinates, fName, h, s, res, b_type, hdr_b_type, 0, hdr_pat,
  17.         elem_pat)
  18.     {
  19.     table = new KH_PX_Table(rect(coordinates.origin.X + 1 + textX(s),
  20.          coordinates.origin.Y + 2 + textY(s),
  21.          coordinates.corner.X - 1 - textX(s),
  22.          coordinates.corner.Y - 3 - textY(s)),
  23.  
  24.          tabName, "", "", 0, b_type, NO_BORDER, FIXED, 0,
  25.          fNo, fields, types);
  26.  
  27.     table->set_ret(1);
  28.     insert(table, 1);
  29.  
  30.     int xw = 2 * pScreenSet->cell_width;
  31.     int yh = pScreenSet->cell_height;
  32.     int xl = screenXL(coordinates.origin.X) + w1->get_shadow();
  33.     int xr = screenXR(coordinates.origin.X) + w1->get_shadow() + xw;
  34.     int yt = screenYT(coordinates.corner.Y) - w1->get_shadow() - 2 * yh;
  35.     int yb = screenYB(coordinates.corner.Y) - w1->get_shadow() - 1 * yh;
  36.  
  37.     home_element = new Element(rect(xl, yt + yh, xr, yb + yh),
  38.              HOME_ELEMENT, BUTTON_BORDER, elem_pat, 1);
  39.     end_element = new Element(rect(xl + xw, yt + yh, xr + xw, yb + yh),
  40.              END_ELEMENT, BUTTON_BORDER, elem_pat, 1);
  41.     ok_element = new Element(rect(xl + 5 * xw, yt + yh, xr + 5 * xw, yb + yh),
  42.              OK_ELEMENT, BUTTON_BORDER, elem_pat, 1);
  43.  
  44.  
  45.     add(ok_element);
  46.     add(home_element);
  47.     add(end_element);
  48.  
  49.     assign(table, left_element, AC_LEFT);
  50.     assign(table, right_element, AC_RIGHT);
  51.     assign(table, up_element, AC_UP);
  52.     assign(table, dn_element, AC_DOWN);
  53.     assign(table, cancel_element, AC_CANCEL);
  54.     assign(table, pg_up_element, AC_PG_UP);
  55.     assign(table, pg_dn_element, AC_PG_DN);
  56.     assign(table, home_element, AC_HOME);
  57.     assign(table, end_element, AC_END);
  58.     assign(table, ok_element, AC_OK);
  59.  
  60.     left_element->repose(rect(xl, yt, xr, yb));
  61.     right_element->repose(rect(xl + xw, yt, xr + xw, yb));
  62.     up_element->repose(rect(xl + 2 * xw, yt, xr + 2 * xw, yb));
  63.     dn_element->repose(rect(xl + 2 * xw, yt + yh, xr + 2 * xw, yb + yh));
  64.     pg_up_element->repose(rect(xl + 3 * xw, yt, xr + 3 * xw, yb));
  65.     pg_dn_element->repose(rect(xl + 3 * xw, yt + yh, xr + 3 * xw, yb + yh));
  66.     if(move_element != NULL)
  67.         move_element->repose(rect(xl + 4 * xw, yt, xr + 4 * xw, yb));
  68.     if(resize_element != NULL)
  69.         resize_element->repose(rect(xl + 4 * xw, yt + yh, xr + 4 * xw, yb + yh));
  70.     cancel_element->repose(rect(xl + 5 * xw, yt, xr + 5 * xw, yb));
  71.     }
  72. /////////////////////////////////
  73. void BlockPXTable::rearrange()
  74.     {
  75.     rect sz = textRect(w1->bound());
  76.     if(sz.width() < 32)
  77.     sz.corner.X = sz.origin.X + 20;
  78.     if(sz.height() < 6)
  79.     sz.corner.Y = sz.origin.Y + 6;
  80.     w1->repose(sz);
  81.     Block::rearrange();
  82.     rect r;
  83.     rect coord = textRect(r = w1->bound());
  84.  
  85.     int xw = 2 * pScreenSet->cell_width;
  86.     int yh = pScreenSet->cell_height;
  87.     int xl = screenXL(coord.origin.X) + w1->get_shadow();
  88.     int xr = screenXR(coord.origin.X) + w1->get_shadow() + xw;
  89.     int yt = screenYT(coord.corner.Y) - w1->get_shadow() - 2 * yh;
  90.     int yb = screenYB(coord.corner.Y) - w1->get_shadow() - 1 * yh;
  91.  
  92.     left_element->repose(rect(xl, yt, xr, yb));
  93.     right_element->repose(rect(xl + xw, yt, xr + xw, yb));
  94.     up_element->repose(rect(xl + 2 * xw, yt, xr + 2 * xw, yb));
  95.     dn_element->repose(rect(xl + 2 * xw, yt + yh, xr + 2 * xw, yb + yh));
  96.     pg_up_element->repose(rect(xl + 3 * xw, yt, xr + 3 * xw, yb));
  97.     pg_dn_element->repose(rect(xl + 3 * xw, yt + yh, xr + 3 * xw, yb + yh));
  98.     home_element->repose(rect(xl, yt + yh, xr, yb + yh));
  99.     end_element->repose(rect(xl + xw, yt + yh, xr + xw, yb + yh));
  100.     if(move_element != NULL)
  101.         move_element->repose(rect(xl + 4 * xw, yt, xr + 4 * xw, yb));
  102.     if(resize_element != NULL)
  103.         resize_element->repose(rect(xl + 4 * xw, yt + yh, xr + 4 * xw, yb + yh));
  104.     cancel_element->repose(rect(xl + 5 * xw, yt, xr + 5 * xw, yb));
  105.     ok_element->repose(rect(xl + 5 * xw, yt + yh, xr + 5 * xw, yb + yh));
  106.  
  107.     table->repose(rect(coord.origin.X + 1 + textX(w1->get_shadow()),
  108.               coord.origin.Y + 2 + textY(w1->get_shadow()),
  109.               coord.corner.X - 1 - textX(w1->get_shadow()),
  110.               coord.corner.Y - 3 - textY(w1->get_shadow())));
  111.     }
  112. /////////////////////////
  113. void BlockPXTable::hide()
  114.     {
  115.     table->hide();
  116.     w1->hide();
  117.     }
  118. //////////////////////////////
  119. /*
  120. void main()
  121.     {
  122.     if(!init_KNOW_HOW())
  123.     return;
  124.     if(PXInit() != PXSUCCESS)
  125.     return;
  126.  
  127.     setfillstyle(SOLID_FILL, pColorSet->colors.BAK_COLOR);
  128.     bar(0, 0, getmaxx(), getmaxy());
  129.  
  130.     BlockPXTable w(rect(10, 2, 78, 14), "demo.db", "window.pcy",
  131.     " KNOW-HOW 4.x", 3, SHOW_BORDER, SHOW_BORDER, MOVE | RESIZE, 19, 0);
  132.  
  133.     w.show_window();
  134.     w.exe();
  135.     w.hide();
  136.  
  137.     PXExit();
  138.     close_KNOW_HOW();
  139.     closegraph();
  140.     }
  141. */